home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
Font.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-27
|
4KB
|
175 lines
#ifndef Font_First
#ifdef __GNUG__
//pragma once
#pragma interface
#endif
#define Font_First
#include "Rectangle.h"
#include "Object.h"
enum GrFont {
eFontTimes,
eFontHelvetica,
eFontCourier,
eFontSymbol,
eFontChicago,
eFontAvantgarde,
eFontBookman,
eFontSchoolbook,
eFontNHelvetica,
eFontPalatino,
eFontChancery,
eFontDingbats,
eFontDefault = eFontTimes
};
enum GrFace {
eFacePlain = 0,
eFaceBold = BIT(0),
eFaceItalic = BIT(1),
eFaceUnderline = BIT(2),
eFaceOutline = BIT(3),
eFaceShadow = BIT(4),
};
enum GrHAdjust {
eAdjHLeft,
eAdjHCenter,
eAdjHRight
};
enum GrVAdjust {
eAdjVBottom,
eAdjVTop,
eAdjVBase,
eAdjVCenter
};
const int cCharsPerFont = 256;
//---- FontFamily --------------------------------------------------------------
class FontFamily : public Object {
public:
GrFont fid;
bool fixed; // is a fixed character font
class OrdCollection *fmap;
public:
MetaDef(FontFamily);
FontFamily(GrFont fid);
~FontFamily();
char *Name();
GrFont Fid()
{ return fid; }
bool Fixed()
{ return fixed; }
class Font *MapSizeFace(int, GrFace);
Font *MapSizeFace2(int size, GrFace face, bool dflt= FALSE);
void InspectorId(char *buf, int bufSize);
void CollectParts(class Collection *);
};
//---- Font --------------------------------------------------------------------
class Font : public Object {
protected:
u_short cw[cCharsPerFont]; // character widths
GrFace face; // style
short size; // point size
short ils; // interline spacing
short ht; // maximum ascender
short bs; // maximum descender
short width; // max width
FontFamily *ff;
class DevFont *dft;
Font(FontFamily*, short size, GrFace face);
public:
MetaDef(Font);
friend Font *new_Font(GrFont fid, int size, GrFace face= eFacePlain);
friend Font *new_Font(GrFont fid, int size, GrFace face, bool real);
DevFont *GetDevFont()
{ return dft; }
int Width(byte c)
{ return cw[c]; }
int Width(byte*, int l= -1);
int MaxWidth(int l= 1);
Metric GetMetric(byte *s, int l= -1);
Metric GetMetric(byte c);
Rectangle BBox(byte *s, int l= -1);
Rectangle BBox(byte c, Point pos);
Point AdjustString(byte *s, Point p, GrVAdjust va, GrHAdjust ha);
int Ascender()
{ return ht; }
int Descender()
{ return bs; }
int Size()
{ return size; }
GrFace Face()
{ return face; }
int Spacing()
{ return ils; }
GrFont Fid()
{ return ff->Fid(); }
bool Fixed()
{ return ff->Fixed(); }
char *Name()
{ return ff->Name(); }
Font *WithFace(GrFace face);
Font *WithSize(int size);
virtual class DevBitmap *CharAsBitmap(byte, Point *offset);
char *AsString();
u_long Hash();
bool IsEqual (Object*);
OStream& PrintOn(OStream&);
Object *ReadAndMap(IStream&);
};
extern Font *gSysFont,
*gApplFont,
*gFixedFont;
//---- FontManager -------------------------------------------------------------
class FontManager : public Object {
protected:
class ObjArray *fmap;
public:
MetaDef(FontManager);
FontManager();
~FontManager();
bool Init(); // returns TRUE on error
virtual Font *MapFont(GrFont fid, int size, GrFace face);
virtual Font *MakeFont(FontFamily*, int size, GrFace face, bool dflt= FALSE);
virtual Font *ScaleFont(FontFamily *ff, int, GrFace);
FontFamily *MapFamily(GrFont fid);
char *StyleString(GrFace face);
GrFont NameToId(char *fontname);
char *IdToName(GrFont fid);
void CollectParts(class Collection *);
};
extern FontManager *gFontManager;
#endif